﻿using UnityEngine;
using System.Collections;
using UnityExample.Common;

public class PlayerScript : MonoBehaviour
{
    public float Speed = 5.0f;
    public float TurnSpeed = 120.0f;

    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        transform.Translate(Vector3.forward * Speed * Time.deltaTime * Input.GetAxis("Vertical"));
        transform.Rotate(Vector3.up * TurnSpeed * Time.deltaTime * Input.GetAxis("Horizontal"));
    }

    void FixedUpdate()
    {
        UnityExampleClient.Instance.SendPacket((ushort)UnityExamplePacketCode.UpdateRequest,
            new UpdatePacket.Request(
                new Position()
        {
            X = transform.position.x,
            Y = transform.position.y,
            Z = transform.position.z
        },
            new Rotation()
        {
            X = transform.rotation.x,
            Y = transform.rotation.y,
            Z = transform.rotation.z,
            W = transform.rotation.w
        }), Lidgren.Network.NetDeliveryMethod.UnreliableSequenced);
    }
}
